 // pages/audit/audit.js
 const app = getApp();
let cookie = wx.getStorageSync('cookieKey');
let header = {};
if (cookie) {
  header.Cookie = cookie;
}
 Page({

   /**
    * 页面的初始数据
    */
   data: {
     arr: null,
     animationData: {},
     showShopPopup: false,
     auExp:"", // 审核说明
     attachId:null // 审核id
   },

   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function(options) {
     app.login();
     var this_ = this;
     let cookie = wx.getStorageSync('cookieKey');
     let header = {};
     if (cookie) {
       header.Cookie = cookie;
     }
     wx.request({
       url: app.globalData.url + 'atsBaseMatch/findAuditAll',
       header: header,
       success(res) {
         console.info(res.data)
         this_.setData({
           arr: res.data
         })
       }
     })
   },

   /**
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady: function() {

   },

   /**
    * 生命周期函数--监听页面显示
    */
   onShow: function() {

   },

   /**
    * 生命周期函数--监听页面隐藏
    */
   onHide: function() {

   },

   /**
    * 生命周期函数--监听页面卸载
    */
   onUnload: function() {

   },

   /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh: function() {

   },

   /**
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function() {

   },

   /**
    * 用户点击右上角分享
    */
   onShareAppMessage: function() {

   },
   oneMenu(e) {
     wx.navigateTo({
       url: '../audits/audits?schemeid=' + e.currentTarget.dataset.schemeid + "&atsschemeexpert=" + e.currentTarget.dataset.atsschemeexpert,
     })

   },
   showModal: function(e) {
    this.setData({
      attachId: e.currentTarget.dataset.schemeid
    })


     // let this_ = this;
     // wx.request({
     //   url: app.globalData.url + 'AtsEmpCoachController/findById',
     //   header: header,
     //   data: {
     //     id: e.currentTarget.dataset.coachid
     //   },
     //   success: res => {
     //     this_.setData({
     //       coach: res.data
     //     })
     //     wx.request({
     //       url: app.globalData.url + 'atsBaseSportController/findById',
     //       header: header,
     //       data: {
     //         id: this_.data.coach.expertSpecia
     //       },
     //       success: res => {
     //         this_.setData({
     //           expertSpecia: res.data.sportName
     //         })
     //       }
     //     })
     //   }
     // })



     // 显示遮罩层
     var animation = wx.createAnimation({
       duration: 200,
       timingFunction: "linear",
       delay: 0
     })
     this.animation = animation
     animation.translateY(300).step()
     this.setData({
       animationData: animation.export(),
       showModalStatus: true
     })
     setTimeout(function() {
       animation.translateY(0).step()
       this.setData({
         animationData: animation.export()
       })
     }.bind(this), 200)
   },
   hideModal: function() {
     // 隐藏遮罩层
     var animation = wx.createAnimation({
       duration: 200,
       timingFunction: "linear",
       delay: 0
     })
     this.animation = animation
     animation.translateY(300).step()
     this.setData({
       animationData: animation.export(),
     })
     setTimeout(function() {
       animation.translateY(0).step()
       this.setData({
         animationData: animation.export(),
         showModalStatus: false
       })
     }.bind(this), 200)
   },
   onShareAppMessage() {
     return {
       title: 'scroll-view',
       path: 'page/component/pages/scroll-view/scroll-view'
     }
   },

   data: {
     toView: 'green'
   },

   upper(e) {},

   lower(e) {},

   scroll(e) {},

   scrollToTop() {
     this.setAction({
       scrollTop: 0
     })
   },

   tap() {
     for (let i = 0; i < order.length; ++i) {
       if (order[i] === this.data.toView) {
         this.setData({
           toView: order[i + 1],
           scrollTop: (i + 1) * 200
         })
         break
       }
     }
   },

   tapMove() {
     this.setData({
       scrollTop: this.data.scrollTop + 10
     })
   }, exps:function(e){
     this.setData({
       auExp: e.detail.value
     })
   }, primary:function(e){
    wx.showLoading({
      title: '加载中',
    })
     if (!this.data.auExp){
        wx.showModal({
          title: '提示',
          content: '审核说明不能为空',
          success: function (res) {
            // if (res.confirm) {
            //   console.log('用户点击确定')
            // } else {
            //   console.log('用户点击取消')
            // }
            return;
          }
       })
     }else{
       var this_ = this;
       wx.request({
         url: app.globalData.url + 'atsAttachmentController/UpdateAuditStateTwo',
         header: header,
         data: {
           attachId: this_.data.attachId,
           auditState: e.currentTarget.dataset.auditstate,
           auExp: this_.data.auExp
         }, success: res => {
           wx.hideLoading();
           wx.redirectTo({
             url: '../audit/audit',
           })
         }
       })
     }
     
     
   }
 })